package com.nari.ies.ne.nw.server.service.plantDataScore.impl;


import com.nari.ies.ne.nw.server.entity.PvDataScoreEntity;
import com.nari.ies.ne.nw.server.mapper.FileScoreMapper;
import com.nari.ies.ne.nw.server.service.plantDataScore.IPvPlantDataScoreService;
import com.nari.ies.ne.nw.server.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class pvPlantDataScoreServiceImpl implements IPvPlantDataScoreService {

    @Autowired
    private FileScoreMapper fileScoreMapper;


    @Override
    public PvDataScoreEntity getXBFZDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "XB-FZ";
        String plantType = "GF";
        String tableName="HISDB.NW_NE_FILE_DATACHECK_GF_XBFZ";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setXB_POWER_SCORES(0);
            pvDataScoreEntity.setXB_THEORY_SCORES(0);
            pvDataScoreEntity.setXB_STATE_SCORES(0);
            pvDataScoreEntity.setXB_COLLECTION_SCORES(0);
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) /dataNum;

                if(dataType.equals("xbPower")){
                    pvDataScoreEntity.setXB_POWER_SCORES(dataScore);
                }

                if(dataType.equals("xbTheory")){
                    pvDataScoreEntity.setXB_THEORY_SCORES(dataScore);
                }
                if(dataType.equals("xbState")){
                    pvDataScoreEntity.setXB_STATE_SCORES(dataScore);
                }
                if(dataType.equals("xbCollection")){
                    pvDataScoreEntity.setXB_COLLECTION_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }

    @Override
    public PvDataScoreEntity getSYZXXDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "SYZXX";
        String plantType = "GF";
        String tableName="HISDB.NW_NE_FILE_DATACHECK_GF_SYZXX";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setSYZXX_SHUNT_SCORES(0);
            pvDataScoreEntity.setSYZXX_REACTIVE_SCORES(0);
            pvDataScoreEntity.setSYZXX_PARALLEL_SCORES(0);
            pvDataScoreEntity.setSYZXX_ACTIVE_SCORES(0);
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) /dataNum;

                if(dataType.equals("shuntActive")){
                    pvDataScoreEntity.setSYZXX_SHUNT_SCORES(dataScore);
                }

                if(dataType.equals("reactive")){
                    pvDataScoreEntity.setSYZXX_REACTIVE_SCORES(dataScore);
                }
                if(dataType.equals("parallel")){
                    pvDataScoreEntity.setSYZXX_PARALLEL_SCORES(dataScore);
                }
                if(dataType.equals("active")){
                    pvDataScoreEntity.setSYZXX_ACTIVE_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }

    @Override
    public PvDataScoreEntity getZTXXDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "ZTXX-QXHJ-TYGZ";
        String plantType = "GF";
        String tableName="HISDB.NW_NE_FILE_DATACHECK_GF_QXHJ";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setZTXX_LONGITUDE_SCORES(0);//升压站经度
            pvDataScoreEntity.setZTXX_LATITUDE_SCORES(0);//升压站纬度
            pvDataScoreEntity.setZTXX_ACTIVE_SCORES(0);//正常发电有功容量
            pvDataScoreEntity.setZTXX_PLANNED_SCORES(0);//计划检修有功容量
            pvDataScoreEntity.setZTXX_MAINTENANCE_SCORES(0);//计划检修台数
            pvDataScoreEntity.setZTXX_LIMITED_SCORES(0);//限电有功容量
            pvDataScoreEntity.setZTXX_LIMITEDNUM_SCORES(0);//限电台数
            pvDataScoreEntity.setZTXX_STANDBY_SCORES(0);//待机有功容量
            pvDataScoreEntity.setZTXX_STANDBYNUM_SCORES(0);//待机台数
            pvDataScoreEntity.setZTXX_COMMUNICATION_SCORES(0);//通讯中断有功容量
            pvDataScoreEntity.setZTXX_COMMUNICATIONNUM_SCORES(0);//通讯中断台数
            pvDataScoreEntity.setZTXX_UNPLANNED_SCORES(0);//非计划停运有功容量
            pvDataScoreEntity.setZTXX_UNPLANNEDNUM_SCORES(0);//非计划停运台数
            pvDataScoreEntity.setZTXX_POWER_SCORES(0);//全站实际出力
            pvDataScoreEntity.setZTXX_CONTROL_SCORES(0);//全站可控容量
            pvDataScoreEntity.setZTXX_THEORY_SCORES(0);//全站理论（最大）有功
            pvDataScoreEntity.setZTXX_TOTAL_RADIO_SCORES(0);//总辐射
            pvDataScoreEntity.setZTXX_DIRECT_RADIO_SCORES(0);//直射辐射
            pvDataScoreEntity.setZTXX_SCATTER_RADIO_SCORES(0);//散射辐射
            pvDataScoreEntity.setZTXX_TEMPER_SCORES(0);//温度
            pvDataScoreEntity.setZTXX_PRESS_SCORES(0);//气压
            pvDataScoreEntity.setZTXX_HUMIDITY_SCORES(0);//湿度
            pvDataScoreEntity.setZTXX_SPEED_SCORES(0);//风速
            pvDataScoreEntity.setZTXX_DIRECTION_SCORES(0);//风向
            pvDataScoreEntity.setZTXX_PVMODULE_TEMP_SCORES(0);//光伏组件温度
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) / dataNum;

                if(dataType.equals("longitude")){
                    pvDataScoreEntity.setZTXX_LONGITUDE_SCORES(dataScore);
                }
                if(dataType.equals("latitude")){
                    pvDataScoreEntity.setZTXX_LATITUDE_SCORES(dataScore);
                }
                if(dataType.equals("normalCapacity")){
                    pvDataScoreEntity.setZTXX_ACTIVE_SCORES(dataScore);
                }
                if(dataType.equals("plannedCapacity")){
                    pvDataScoreEntity.setZTXX_PLANNED_SCORES(dataScore);
                }
                if(dataType.equals("plannedNumber")){
                    pvDataScoreEntity.setZTXX_MAINTENANCE_SCORES(dataScore);
                }

                if(dataType.equals("limitedCapacity")){
                    pvDataScoreEntity.setZTXX_LIMITED_SCORES(dataScore);
                }
                if(dataType.equals("limitedNumber")){
                    pvDataScoreEntity.setZTXX_LIMITEDNUM_SCORES(dataScore);
                }
                if(dataType.equals("standbyCapacity")){
                    pvDataScoreEntity.setZTXX_STANDBY_SCORES(dataScore);
                }
                if(dataType.equals("standbyNumber")){
                    pvDataScoreEntity.setZTXX_STANDBYNUM_SCORES(dataScore);
                }
                if(dataType.equals("interruptCapacity")){
                    pvDataScoreEntity.setZTXX_COMMUNICATION_SCORES(dataScore);
                }

                if(dataType.equals("interruptNumber")){
                    pvDataScoreEntity.setZTXX_COMMUNICATIONNUM_SCORES(dataScore);
                }
                if(dataType.equals("unplannedCapacity")){
                    pvDataScoreEntity.setZTXX_UNPLANNED_SCORES(dataScore);
                }
                if(dataType.equals("unplannedNumber")){
                    pvDataScoreEntity.setZTXX_UNPLANNEDNUM_SCORES(dataScore);
                }
                if(dataType.equals("poweraLL")){
                    pvDataScoreEntity.setZTXX_POWER_SCORES(dataScore);
                }
                if(dataType.equals("controlCapacity")){
                    pvDataScoreEntity.setZTXX_CONTROL_SCORES(dataScore);
                }

                if(dataType.equals("theoryPower")){
                    pvDataScoreEntity.setZTXX_THEORY_SCORES(dataScore);
                }
                if(dataType.equals("totalRadio")){
                    pvDataScoreEntity.setZTXX_TOTAL_RADIO_SCORES(dataScore);
                }
                if(dataType.equals("directRadio")){
                    pvDataScoreEntity.setZTXX_DIRECT_RADIO_SCORES(dataScore);
                }
                if(dataType.equals("scatterRadio")){
                    pvDataScoreEntity.setZTXX_SCATTER_RADIO_SCORES(dataScore);
                }
                if(dataType.equals("temper")){
                    pvDataScoreEntity.setZTXX_TEMPER_SCORES(dataScore);
                }


                if(dataType.equals("press")){
                    pvDataScoreEntity.setZTXX_PRESS_SCORES(dataScore);
                }
                if(dataType.equals("humidity")){
                    pvDataScoreEntity.setZTXX_HUMIDITY_SCORES(dataScore);
                }
                if(dataType.equals("speed")){
                    pvDataScoreEntity.setZTXX_SPEED_SCORES(dataScore);
                }
                if(dataType.equals("direction")){
                    pvDataScoreEntity.setZTXX_DIRECTION_SCORES(dataScore);
                }
                if(dataType.equals("pvModuleTemper")){
                    pvDataScoreEntity.setZTXX_PVMODULE_TEMP_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }

    @Override
    public PvDataScoreEntity getDQYCDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "DQYC";
        String plantType = "GF";
        String tableName="HISDB.NW_NE_FILE_DATACHECK_GF_DQYC";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setDQYC_PREDICTION_SCORES(0);
            pvDataScoreEntity.setDQYC_PLANNED_SCORES(0);
            pvDataScoreEntity.setDQYC_OPERATING_SCORES(0);
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) /dataNum;

                if(dataType.equals("power")){
                    pvDataScoreEntity.setDQYC_PREDICTION_SCORES(dataScore);
                }
                if(dataType.equals("capacity")){
                    pvDataScoreEntity.setDQYC_PLANNED_SCORES(dataScore);
                }
                if(dataType.equals("operating")){
                    pvDataScoreEntity.setDQYC_OPERATING_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }

    @Override
    public PvDataScoreEntity getCDQYCDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "CDQYC";
        String plantType = "FD";
        String tableName = "HISDB.NW_NE_FILE_DATACHECK_FD_CDQYC";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setCDQYC_PREDICTION_SCORES(0);
            pvDataScoreEntity.setCDQYC_OPERATING_SCORES(0);
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) / dataNum;

                if(dataType.equals("power")){
                    pvDataScoreEntity.setCDQYC_PREDICTION_SCORES(dataScore);
                }

                if(dataType.equals("capacity")){
                    pvDataScoreEntity.setCDQYC_OPERATING_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }

    @Override
    public PvDataScoreEntity getTJXXDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "TJXX";
        String plantType = "GF";
        String tableName="HISDB.NW_NE_FILE_DATACHECK_GF_TJXX";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setTJXX_XB_NUM_SCORES(0);
            pvDataScoreEntity.setTJXX_INVERTER_NUM_SCORES(0);
            pvDataScoreEntity.setTJXX_CAPACITY_SCORES(0);
            pvDataScoreEntity.setTJXX_ACTIVE_SCORES(0);
            pvDataScoreEntity.setTJXX_REACTIVE_SCORES(0);
            pvDataScoreEntity.setTJXX_AVAILABLE_SCORES(0);
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) / dataNum;

                if(dataType.equals("xbNum")){
                    pvDataScoreEntity.setTJXX_XB_NUM_SCORES(dataScore);
                }
                if(dataType.equals("nbqNum")){
                    pvDataScoreEntity.setTJXX_INVERTER_NUM_SCORES(dataScore);
                }
                if(dataType.equals("capacity")){
                    pvDataScoreEntity.setTJXX_CAPACITY_SCORES(dataScore);
                }
                if(dataType.equals("power")){
                    pvDataScoreEntity.setTJXX_ACTIVE_SCORES(dataScore);
                }
                if(dataType.equals("reactivePower")){
                    pvDataScoreEntity.setTJXX_REACTIVE_SCORES(dataScore);
                }
                if(dataType.equals("availablePower")){
                    pvDataScoreEntity.setTJXX_AVAILABLE_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }

    @Override
    public PvDataScoreEntity getNBQHLXDataScore(PvDataScoreEntity pvDataScoreEntity) {
        String plantId = pvDataScoreEntity.getPlantId();
        Date endDate = pvDataScoreEntity.getDateTime();
        Date startDate = DateUtil.getYesterdayTime(endDate);
        String fileType = "NBQ-HLX";
        String plantType = "GF";
        String tableName="HISDB.NW_NE_FILE_DATACHECK_GF_NBQHLX";

        //获取昨天该类型文件文件所有数据评分项
        List<Map<String,Object>> fileData = fileScoreMapper.selectFileData(plantId,fileType,plantType,startDate,endDate,tableName);
        //获取该类型文件的数据项和对应分数
        List<Map<String,Object>> dataList = fileScoreMapper.selectFileDataType(fileType,plantType);

        int dataNum =0;
        if(fileData==null||fileData.size()==0||dataList==null){
            pvDataScoreEntity.setNBQ_MAX_OUTPUT_SCORES(0);
            pvDataScoreEntity.setNBQ_CONNECTED_SCORES(0);
            pvDataScoreEntity.setNBQ_OVERHAUL_SCORES(0);
            pvDataScoreEntity.setNBQ_FAULT_STATUS_SCORES(0);
            pvDataScoreEntity.setNBQ_RATIONING_SCORES(0);
            pvDataScoreEntity.setNBQ_SHUTDOWN_SCORES(0);
            pvDataScoreEntity.setNBQ_INTERRUPTION_SCORES(0);
            pvDataScoreEntity.setNBQ_WIRE_STATUS_SCORES(0);
        }else {
            dataNum = Integer.parseInt(fileData.get(0).get("NUM").toString());
            for (Map<String, Object> map : dataList) {
                //无数据数量
                int noDataNum = 0;
                //合格数据数量
                int qualifiedNum = 0;
                //不合格数据数量
                int unqualifiedNum = 0;
                String dataType = map.get("DATA_TYPE").toString();
                float score = Float.parseFloat(map.get("SCORE").toString());

                for (Map<String, Object> fileDaMap : fileData) {
                    String fileDataType = fileDaMap.get("DATA_TYPE").toString();
                    if (fileDataType.equals(dataType)) {
                        noDataNum += Integer.parseInt(fileDaMap.get("NO_DATA").toString());
                        qualifiedNum += Integer.parseInt(fileDaMap.get("QUALIFIED_DATA").toString());
                        unqualifiedNum += Integer.parseInt(fileDaMap.get("UNQUALIFIED_DATA").toString());
                    }
                }
                //单项数据得分
                float dataScore = (float) ((qualifiedNum + unqualifiedNum * 0.5 + noDataNum * 0) * score) / dataNum;

                if(dataType.equals("nbqMaxOutput")){
                    pvDataScoreEntity.setNBQ_MAX_OUTPUT_SCORES(dataScore);
                }
                if(dataType.equals("nbqConnected")){
                    pvDataScoreEntity.setNBQ_CONNECTED_SCORES(dataScore);
                }
                if(dataType.equals("nbqOverhaul")){
                    pvDataScoreEntity.setNBQ_OVERHAUL_SCORES(dataScore);
                }
                if(dataType.equals("nbqFaultStatus")){
                    pvDataScoreEntity.setNBQ_FAULT_STATUS_SCORES(dataScore);
                }
                if(dataType.equals("nbqRationing")){
                    pvDataScoreEntity.setNBQ_RATIONING_SCORES(dataScore);
                }
                if(dataType.equals("nbqShutdown")){
                    pvDataScoreEntity.setNBQ_SHUTDOWN_SCORES(dataScore);
                }
                if(dataType.equals("nbqInterruption")){
                    pvDataScoreEntity.setNBQ_INTERRUPTION_SCORES(dataScore);
                }
                if(dataType.equals("nbqWireStatus")){
                    pvDataScoreEntity.setNBQ_WIRE_STATUS_SCORES(dataScore);
                }
            }
        }
        return pvDataScoreEntity;
    }
}
